﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System;
using System.Xml.Serialization;
using System.Text;
using System.Threading;
using System.ComponentModel;
using System.Collections;
using System.Collections.Generic;
using BrainTechLLC.ThreadSafeObjects;
using System.Runtime.Serialization;
using System.Reflection;
using System.Diagnostics;
#if USE_HYPER
using Hyper.ComponentModel;
#endif

namespace BrainTechLLC
{
	[Serializable]
    public class ExternalInfluence : BaseClass, IGameThing, INotifyPropertyChanged, INotifyPropertyChanging 
	{
		public string InfluenceMethodName { get; set; }
		public string InfluenceTypeName { get; set; }

		public GetInfluenceDelegate GetInfluenceMethod
		{
			get
			{
				try
				{
					Type t = InfluenceTypeName.GetType(null, true);
					MethodInfo mi = t.GetMethod(InfluenceMethodName, BindingFlags.Static | System.Reflection.BindingFlags.Public);

					if (mi == null)
						throw new Exception(String.Format("InfluenceMethodName {0} of type {1} not found", InfluenceMethodName, t.Name));

					return (GetInfluenceDelegate)Delegate.CreateDelegate(typeof(GetInfluenceDelegate), mi);
				}
				catch (Exception ex)
				{
                    Debug.WriteLine(ex.ToString());
					Console.WriteLine(ex.ToString());
					throw;
				}
			}
		}

		public long CausedByID { get; set; }
		public string InfluenceName { get; set; }

		public int Priority { get; set; }
		public string InfluenceEvent { get; set; }
	}
}